<%@ page contentType="text/html;charset=utf-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>便民服务平台3.0</title>
</head>


<body>
<jsp:include page="../include/header.jsp"/>
<script src="<c:url value='/resource/js/lib/template.js'/>"></script>


<div class="main-container">
    <div class="mc-hd">
        <p class="police-t">police affairs public</p>
        <h1 class="police-h1">专注高端”互联网+政务”设计</h1>
        <div class="type-wrap">
            <h2 class="typedH2">慧眼看世界，在政务服务的路上不断追求创新！</h2>
        </div>
    </div>
    <div class="mc-bd">
        <div class="container">
            <div class="row">
                <div class="col-sm-3">
                    <div class="mccc-left">
                        <h2>警务公开</h2>
                        <ul class="nav nav-pills nav-stacked" role="tablist">
                            <li id="nav-jwzx" data-ns="jwzx" class="active"><a href="javascript:;">警务资讯<i
                                    class="caret-right"></i></a></li>
                            <li id="nav-gsgg" data-ns="gsgg"><a href="javascript:;">公示公告<i
                                    class="caret-right"></i></a></li>
                            <li id="nav-jyfc" data-ns="jyfc"><a href="javascript:;">警营风采<i
                                    class="caret-right"></i></a></li>
                            <li id="nav-jjjs" data-ns="jjjs"><a href="javascript:;">警界警事<i
                                    class="caret-right"></i></a></li>
                            <%--<li id="nav-ztzl" data-ns="ztzl"><a href="javascript:;">专题专栏<i--%>
                                    <%--class="caret-right"></i></a></li>--%>
                            <%--<li id="nav-zfxxgk" data-ns="zfxxgk"><a href="javascript:;">政府信息公开<i--%>
                                    <%--class="caret-right"></i></a></li>--%>
                        </ul>
                    </div>
                </div>
                <div class="col-sm-9">
                    <div id="mainContent">
                        <div class="mccc-right">
                            <h2>警务资讯</h2>
                            <div class="panel panel-default">
                                <div class="panel-body pa-search">
                                    <div class="form-inline">
                                        <div class="form-group">
                                            <label>公告标题：</label>
                                            <input type="text" class="form-control" id="title"
                                                   placeholder="请输入公告标题">
                                        </div>
                                        <div class="form-group">
                                            <label>发布时间：</label>
                                            <input type="text" class="form-control laydate-icon" style="width:130px;cursor: pointer"
                                                   id="startTime" readonly="readonly"> 至
                                            <input type="text" class="form-control laydate-icon" style="width:130px;cursor: pointer"
                                                   id="endTime" readonly="readonly">
                                        </div>
                                        <div class="form-group">
                                            <button id="callBackPagination" class="btn btn-blue">查询
                                            </button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div>
                                <div id="mytask_clz_dv" class="ucr-centent">
                                </div>
                                <div style="text-align: center;"><ul class="pagination" id="pagination2"></ul></div>
                            </div>
                            <script id="mytask_clz_dv_attid" type="text/html">
                                <table id="mytask_table" class="table table-border">
                                    <colgroup>
                                        <col width="10%">
                                        <col width="70%">
                                        <col width="20%">
                                    </colgroup>
                                    <thead>
                                    <tr>
                                        <th>序号</th>
                                        <th>公告标题</th>
                                        <th>发布时间</th>
                                    </tr>
                                    </thead>
                                    <tbody id="trcontent">
                                    {{if list.length < 1}}
                                    <tr>
                                        <td colspan="3">
                                            暂未找到数据
                                        </td>
                                    </tr>
                                    {{/if}}
                                    {{each list as value i}}
                                    <tr>
                                        <td>
                                            {{(pageIndex - 1) * pageSize + (i+1)}}
                                        </td>
                                        <td>
                                            <%--<a href="javascript:;" id="guid_{{value.guid}}" data-guid={{value.guid}} data-category={{value.category}}>{{value.title}}</a>--%>
                                            <a href="<c:url value='/news/newsdetail'/>?guid={{value.guid}}&type={{value.category?value.category:'gsgg'}}" id="guid_{{value.guid}}" target="_blank">{{value.title}}</a>
                                        </td>
                                        <td>
                                            {{value.publicTime}}
                                        </td>
                                    </tr>
                                    {{/each}}
                                    </tbody>
                                </table>
                            </script>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>
</div>
<jsp:include page="../include/footer.jsp"/>
<script src="<c:url value='/resource/js/require.js'/>" data-main="<c:url value='/resource/js/main.js'/>" id="current-page" current-page="policeAffairs"></script>

<script type="text/javascript">
    var type = "${type}";
    var browserurl = window.document.location.pathname;
    var context = browserurl.indexOf("/") != -1 ? browserurl.substring(0, browserurl.substr(1).indexOf('/') + 1) : "";
    require.config({
        baseUrl: context + "/resource/js",
        paths: {
            jquery: 'jquery-1.9.1.min',
            bootstrap: "lib/bootstrap.min",
            jqPaginator: "lib/jqPaginator",
            widget: "jquery.ui.widget"
        }
    });
    require( ["jquery", "jqPaginator","widget","bootstrap"],
            function($,jqPaginator,widget,bootstrap) {
                $(function(){
                    callBackPagination(type, '0');
                    $("#callBackPagination").click(function(){
                        callBackPagination('','0')
                    });
                    $('.nav-pills li[id^=nav-]').click(function(){
                       //console.log($(this).data().ns)
                        callBackPagination($(this).data().ns,'0')
                    })
                })

                function callBackPagination(caseType, loadtype) {
                    if ("" != caseType) {
                        type = caseType;
                        $("#" + caseType).siblings().removeClass("active");
                        $("#" + caseType).addClass("active");
                        clearValue();
                    }

                    var limit = 8;
                    var currPage = 1;

                    new Paging({
                        type: 'GET',
                        data: {
                            ps: limit,
                            pi: currPage,
                            type: type,
                            title: $('#title').val(),
                            start: $("#startTime").val(),
                            end: $("#endTime").val()
                        },
                        url: '<c:url value="/news/newslist"></c:url>',
                        tempId: "mytask_clz_dv_attid",
                        paginger: "pagination2",
                        containerId: "mytask_clz_dv",
                        errorCallback: function (data) {
                            console.log(data);
                        }
                    }).getPagList();
                }

                function clearValue(){
                    $("#title").val("");
                    $("#startTime").val("");
                    $("#endTime").val("");
                }

                function Paging(option) {
                    var myoption = option || {};
                    this.getPagList = function () {
                        var myurl = myoption.url;
                        $.ajax({
                            type: myoption.type,
                            url: myurl,
                            data: myoption.data,
                            dataType: "json",
                            success: function (resp) {
                                resp = eval(resp);
                                var shtml = template(myoption.tempId, resp.data);
                                $("#" + myoption.containerId).html(shtml);
                                paginator(resp.data);
                            },
                            error: function (resp) {
                                if (typeof (option.errorCallback) == "function") {
                                    option.errorCallback(resp);
                                }
                            }
                        });
                    }

                    //设置分页条数据（私有方法）
                    function paginator(resdata) {

                        var _trow = resdata.totalRow == 0 ? 1 : resdata.totalRow;

                        $.jqPaginator('#' + myoption.paginger, {
                            totalCounts: _trow,
                            pageSize: resdata.pageSize,
                            visiblePages: 10,
                            currentPage: resdata.pageIndex,
                            first: '<li class="first"><a href="javascript:;">首页</a></li>',
                            prev: '<li class="prev"><a href="javascript:;">上一页</a></li>',
                            next: '<li class="next"><a href="javascript:;">下一页</a></li>',
                            last: '<li class="last"><a href="javascript:;">尾页</a></li>',
                            page: '<li class="page"><a href="javascript:;">{{page}}</a></li>',
                            onPageChange: function (num, type) {
                                if (type == "change") {
                                    var custom = option;
                                    // console.log(custom);
                                    custom.data.pi = num;

                                    new Paging(custom).getPagList();
                                }
                            }
                        });
                    }
                }
                //暂时不需要
                function detail(guid, type) {
                    if (type == "") {
                        type = "gsgg";
                    }
                    window.open('<c:url value="/news/newsdetail"/>' + "?guid=" + guid + "&type=" + type);
                }
            })

</script>

</body>
</html>






